Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix passing empty masterkey #585

Merged
merged 6 commits into from
Oct 25, 2023

Conversation

mmachatschek
Copy link
Collaborator

@mmachatschek mmachatschek commented Oct 11, 2023

Pull Request

Related issue

Fixes #584

What does this PR do?

  • Fix the issue by also checking if the provided masterkey is an empty string

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

@curquiza curquiza added the bug Something isn't working label Oct 11, 2023
tests/Http/ClientTest.php Outdated Show resolved Hide resolved
@mmachatschek
Copy link
Collaborator Author

@curquiza I didn't revert to the previous behaviour, instead I opted for an check if the user provided an empty string. Empty string can not be passed via authorization anyway so I think this should be safe

Co-authored-by: Tomas Norkūnas <[email protected]>
@mmachatschek mmachatschek marked this pull request as draft October 11, 2023 11:49
norkunas
norkunas previously approved these changes Oct 11, 2023
Copy link
Collaborator

@norkunas norkunas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On new major release I'd leave as is documenting that non-empty-string or null are accepted, so maybe a note for future could be added

Comment on lines 242 to 244
if ('Authorization' === $name) {
$this->assertSame('Bearer ', $value);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this actually tests the wrong thing. I'll update the test now

Copy link
Collaborator

@norkunas norkunas Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, should be if ('Authorization' === $name) { self::fail(); } :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@norkunas thanks for the suggestion, didn't see the comment while providing a fix 😅 didn't write PHP tests in a while.

Can you check the latest commit?

dd2d9db

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on the second thought, as there is $this->once(), the else case will never be reached I think.
so this would be enough:

        $requestStub->expects($this->once())
            ->method('withAddedHeader')
            ->willReturnCallback(function ($name, $value) use ($requestStub) {
                $this->assertSame('User-Agent', $name);
                $this->assertSame(Meilisearch::qualifiedVersion(), $value);

@mmachatschek
Copy link
Collaborator Author

On new major release I'd leave as is documenting that non-empty-string or null are accepted, so maybe a note for future could be added

@norkunas I don't quite understand. What do you exactly mean?

@mmachatschek mmachatschek marked this pull request as ready for review October 11, 2023 12:06
@norkunas
Copy link
Collaborator

On new major release I'd leave as is documenting that non-empty-string or null are accepted, so maybe a note for future could be added

@norkunas I don't quite understand. What do you exactly mean?

I mean to add a note about #514 (comment) to not forget it in future :)

Co-authored-by: Tomas Norkūnas <[email protected]>
brunoocasali
brunoocasali previously approved these changes Oct 24, 2023
Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@norkunas
Copy link
Collaborator

Maybe we should add deprecation?

@curquiza
Copy link
Member

bors try

meili-bors bot added a commit that referenced this pull request Oct 25, 2023
@meili-bors
Copy link
Contributor

meili-bors bot commented Oct 25, 2023

try

Build failed:

@curquiza
Copy link
Member

@mmachatschek @norkunas I think the tests are still failing 😕

@mmachatschek
Copy link
Collaborator Author

@curquiza @brunoocasali I pushed the fix. lets retry with bors

@norkunas
Copy link
Collaborator

Strange to have two Client classes :)

@norkunas
Copy link
Collaborator

bors merge

meili-bors bot added a commit that referenced this pull request Oct 25, 2023
585: Fix passing empty masterkey r=norkunas a=mmachatschek

# Pull Request

## Related issue
Fixes #584

## What does this PR do?
- Fix the issue by also checking if the provided masterkey is an empty string

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: Markus Machatschek <[email protected]>
Co-authored-by: Bruno Casali <[email protected]>
@meili-bors
Copy link
Contributor

meili-bors bot commented Oct 25, 2023

This PR was included in a batch that successfully built, but then failed to merge into main. It will not be retried.

Additional information:

{"message":"At least 1 approving review is required by reviewers with write access.","documentation_url":"https://docs.github.com/articles/about-protected-branches"}

@norkunas
Copy link
Collaborator

bors merge

@meili-bors
Copy link
Contributor

meili-bors bot commented Oct 25, 2023

@mmachatschek mmachatschek merged commit 048eb90 into main Oct 25, 2023
9 checks passed
@mmachatschek mmachatschek deleted the issue/584-issue-when-upgrading-from--13-to--13 branch October 25, 2023 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue when upgrading from < 1.3 to >= 1.3 with api keys set to empty string
4 participants